emojicompletion: Avoid a memory overrun
authorMatthias Clasen <mclasen@redhat.com>
Thu, 15 Oct 2020 19:16:06 +0000 (15:16 -0400)
committerMatthias Clasen <mclasen@redhat.com>
Thu, 15 Oct 2020 20:32:55 +0000 (16:32 -0400)
Don't read beyond the beginning of the string.

Fixes: #3245
gtk/gtkemojicompletion.c

index 712418850a017a22998ad16f06d98e107c2b881d..31669c85d5adcec9a77988dfaa8cd5f3dae65252 100644 (file)
@@ -115,7 +115,8 @@ next:
               break;
             }
         }
-      while (g_unichar_isalnum (g_utf8_get_char (p)) || *p == '_' || *p == ' ');
+      while (p > text &&
+             (g_unichar_isalnum (g_utf8_get_char (p)) || *p == '_' || *p == ' '));
 
       if (found_candidate)
         n_matches = populate_completion (completion, p, 0);